.TH std::experimental::source_location::file_name 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::source_location::file_name \- std::experimental::source_location::file_name

.SH Synopsis
   constexpr const char* file_name() const noexcept;  (library fundamentals TS v2)

   Returns the name of the current source file represented by this object, represented
   as a null-terminated byte string.

.SH Parameters

   \fI(none)\fP

.SH Return value

   The name of the current source file represented by this object, represented as a
   null-terminated byte string.

.SH Example


// Run this code

 #include <experimental/source_location>
 #include <iostream>

 inline void print_this_file_name(
     const std::experimental::source_location& location
         = std::experimental::source_location::current())
 {
     // Name of file that contains the call-site of this function.
     std::cout << "File: " << location.file_name() << '\\n';
 }

 int main()
 {
     print_this_file_name();
 }

.SH Possible output:

 File: main.cpp

.SH See also

   line          return the line number represented by this object
                 \fI(public member function)\fP
   column        return the column number represented by this object
                 \fI(public member function)\fP
   function_name return the name of the function represented by this object, if any
                 \fI(public member function)\fP
   C++ documentation for
   Filename and line information
